package com.gui.hospital.controller;

import com.gui.entity.R;
import com.gui.hospital.model.HospitalDepartment;
import com.gui.hospital.model.Scheduling;
import com.gui.hospital.service.HospitalDepartmentService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 言叶
 * Date：2025/9/4
 */
@RestController
@RequestMapping("/hospitalDepartment")
@CrossOrigin
@AllArgsConstructor
public class HospitalDepartmentController {

    private final HospitalDepartmentService hospitalDepartmentService;
    //根据医院id查询所有一级科室
    @GetMapping("/findByHospitalId/{hospitalId}")
    public R<List<HospitalDepartment>> findByHospitalId(@PathVariable Integer hospitalId)
    {
        List<HospitalDepartment> list = hospitalDepartmentService.findByHospitalId(hospitalId);
        return new R<>(list);
    }

    /*
     * 根据上级科室id查询下级科室
     */
    @GetMapping("/findByPid/{pid}")
    public R<List<HospitalDepartment>> findByPid(@PathVariable Integer pid) {
        return new R<>(hospitalDepartmentService.findByPid(pid));
    }
    /*
     * 根据id查询科室信息
     */
    @GetMapping("/getById/{id}")
    public HospitalDepartment getHospitalDepartmentById(@PathVariable("id") Integer id) {
        return hospitalDepartmentService.getById(id);
    }

}
